using System;
using Microsoft.AspNetCore.Mvc;
using WebApiFrame.Filters;
using WebApiFrame.Models;
using WebApiFrame.Repositories;

namespace WebApiFrame.Controllers
{
    [Route("api/[controller]")]
    public class UsersController:ControllerBase
    {
        private readonly IUsersRepository _userRepository;
  public  UsersController(IUsersRepository userRepository)
        {
        _userRepository=userRepository;
        }
      
        
        [HttpGet("{id}")]
        [MyActionFilter]
      public IActionResult Get(int id)
      {
var user=_userRepository.GetById(id);
return new ObjectResult(user);
      } 
   [HttpGet("")]
    public IActionResult GetAll()
    {
        var users=_userRepository.GetAll();
return new ObjectResult(users);
    } 

    }
}